<?php

namespace McUser\Model;
use Common\Model\CommonModel;
load("@.myfunc");

/*
 *  Copyright (c) 2014 The CCP project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a Beijing Speedtong Information Technology Co.,Ltd license
 *  that can be found in the LICENSE file in the root of the web site.
 *
 *   http://www.yuntongxun.com
 *
 *  An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

class SmsHisModel extends CommonModel {

	protected $trueTableName = 'bg_sms_his';
	
	/**
	 * 得到IP地址.
	 */
	public function getip()
	{
	    if(!empty($_SERVER["HTTP_CLIENT_IP"]))
	    {
	        $cip = $_SERVER["HTTP_CLIENT_IP"];
	    }
	    else if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"]))
	    {
	        $cip = $_SERVER["HTTP_X_FORWARDED_FOR"];
	    }
	    else if(!empty($_SERVER["REMOTE_ADDR"]))
	    {
	        $cip = $_SERVER["REMOTE_ADDR"];
	    }
	    else
	    {
	        $cip = '';
	    }

	    preg_match("/[\d\.]{7,15}/", $cip, $cips);
	    $cip = isset($cips[0]) ? $cips[0] : 'unknown';
	    unset($cips);
	    return $cip;
	}

	/*
	*	保存 smsData 
	*/
	public function save_data($mobile, $smsData, $smsStatusCode){
		
		$data['mobile'] = $mobile;
		$data['smsData'] = $smsData;
		$data['smsStatusCode'] = $smsStatusCode;
		$data['sendDate'] = date('Y-m-d', time());
		$data['sendTime'] = date('H:i:s', time());
		
		$this -> add($data);		
	}

	

}